package com.l024.easyandroidlib.log.printer;




import static com.l024.easyandroidlib.log.config.EasyLogConfig.MAX_LEN;

import android.util.Log;

import androidx.annotation.NonNull;

import com.l024.easyandroidlib.log.config.EasyLogConfig;


/**
 * @author wu_ming_zhi_bei
 * @date 2021/1/28 22:25
 * @Notes
 */
public class EasyLogConsolePrinter implements EasyLogPrinter {
    @Override
    public void print(@NonNull EasyLogConfig config, int level, String tag, @NonNull String prientString) {
        int len = prientString.length();
        int countOfSub = len/MAX_LEN;
        if(countOfSub>0){
            int index = 0;
            for(int i=0;i<countOfSub;i++){
                Log.println(level,tag,prientString.substring(index,index+MAX_LEN));
                index+=MAX_LEN;
            }
            if(index!=len){
                Log.println(level,tag,prientString.substring(index,len));
            }
        }else{
            //不足一行也打印
            Log.println(level,tag,prientString);
        }
    }
}
